package com.cy.pj.arithmetic.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice//ControllerAdvice + ResponseBody,表示这个类是全局异常处理类
public class GlobalExceptionHandle {
    @ExceptionHandler(ArithmeticException.class)
    public String doHandleArithmeticException(ArithmeticException e){
        return "do compute error,cause by "+e.getMessage();
    }
    @ExceptionHandler(RuntimeException.class)
    public String doHandleRuntimeException(RuntimeException e){
        return "do Runtime error,cause by "+e.getMessage();
    }


}
